{extend name='common/common' /}

{block name="style"}
<style type="text/css">
    .container-fluid .btn.btn-sm{
        float: right;
        margin-left: 10px;
    }
    .container-fluid{
        padding-right: 0px;
    }
    .layui-form-item{
        margin-bottom: 0px;
    }
    .layui-form-item .layui-inline{
        margin-right: 0px;
    }
    .king{
        margin-right: 10px;
    }
    .layui-form{
        display: inline-block;
    }
	tr{
		cursor: pointer;
	}
</style>
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>资源列表</h5>
        </div>
        <div class="ibox-content">
            <!--<div class="container-fluid form-inline pull-right" style="margin-top: 10px">-->
                <!--<button class="btn btn-danger btn-sm getIDs" data-delete="{:url('member/deleteList')}" data-param="">删除会员</button>-->
            <!--</div>-->
            <!--搜索框开始 pull-right-->

            {if(authCheck('member/memberlist'))}
            <!--  用户本人的客户列表  -->
            <form id='commentForm' data-url="{:url('Business/resouMember')}" role="form" method="post" class="form-inline pull-left">
                <div class="content clearfix m-b">
                    <div class="form-group">
                        <label>客户姓名：</label>
                        <input type="text" class="form-control" id="name" name="name">
                    </div>
                    <div class="form-group">
                        <label>联系方式：</label>
                        <input type="text" class="form-control" id="phone" name="phone">
                    </div>
					<!-- 资源客户状态 -->
					<div class="form-group">
                        <label>联系状态：</label>
						<select name="seaResStatus" id="seaResStatus" class="form-control">
							<option value="">请选择</option>
							<?php foreach($resStatus as $val):?>
								<option value="<?=$val['id'];?>"><?=$val['name'];?></option>
							<?php endforeach;?>
						</select>
                    </div>
                    <!-- 新增时间  -->
                    <div class="form-group">
                        <label>日期范围：</label>
                        <div class="layui-form">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="KL-time" id="KL-time" placeholder="开始 到 结束">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
                        </button>
                    </div>
                </div>
            </form>
            {/if}
            <!--  主管客户列表  -->
            <!--搜索框结束-->
            <div class="example-wrap">
                <div class="example">
                    <table id="cusTable">
                        <thead>
                        <th>checkbox</th>
                        <th class="text-center" data-width="100px" data-field="id">会员ID</th>
                        <th class="text-center" data-width="100px" data-field="name">姓名</th>
                        <th class="text-center" data-width="120px" data-field="phone">联系电话</th>
                        <th class="text-center" data-width="200px" data-field="adress">地址</th>
                        <th class="text-center" data-width="120px" data-field="qq">QQ</th>
                        <th class="text-center" data-width="120px" data-field="weixin">微信</th>
                        <th class="text-center" data-width="100px" data-field="statusN">状态</th>
                        <th class="text-center" data-width="100px" data-field="first_relation">录入人</th>
                        <th class="text-center" data-width="120px" data-field="entry_time">录入时间</th>
                        <th class="text-center" data-width="150px" data-field="remarks">备注</th>
												<th class="text-center" data-width="100px" data-field="resStatus">资源状态</th>
                        <th class="text-center" data-width="250px" data-field="operate">操作</th>
                        </thead>
                    </table>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
<div class="laycontent" style="display: none;width: 300px;padding: 30px 15px;">
    <ul id="tree"></ul>
</div>

<div id="trackInfo" style="display: none;padding-top: 15px;">
	<div class="form-group">
		<label class="col-sm-4 control-label" style="padding-top:8px">资源客源状态：</label>
		<div class="input-group col-sm-7">
			<select name="resStatus" id="resStatus" class="form-control">
				<option value="">请选择</option>
				<?php foreach($resStatus as $val):?>
					<option value="<?=$val['id'];?>"><?=$val['name'];?></option>
				<?php endforeach;?>
			</select>
		</div>
	</div>
	<!-- <div class="form-group">
		<label class="col-sm-4 control-label">跟踪备注：</label>
		<div class="input-group col-sm-7">
			<textarea name="content" id="content" class="form-control" cols="10" rows="10"></textarea>
		</div>
	</div> -->
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    function initTable() {
        var url = $("#commentForm").attr('data-url');
//        alert(url);
        //先销毁表格
        $('#cusTable').bootstrapTable('destroy');
        //初始化表格,动态从服务器加载数据
        $("#cusTable").bootstrapTable({
            method: "get",  //使用get请求到服务器获取数据
            url: url, //获取数据的地址
            striped: true,  //表格显示条纹
            pagination: true, //启动分页
            pageSize: 10,  //每页显示的记录数
            pageNumber:1, //当前第几页
            pageList: [5, 10, 15, 20, 25],  //记录数可选列表
            sidePagination: "server", //表示服务端请求
						resizable:true,//可变宽列表
            paginationFirstText: "首页",
            paginationPreText: "上一页",
            paginationNextText: "下一页",
            paginationLastText: "尾页",
            queryParamsType : "undefined",
            columns : [{
                checkbox: true,
                formatter:function(value,row,index){
                    if (row.state == true){
                        return {
                            checked : value,//设置选中
                        };
                    }
                    return value;
                },
            }],
            queryParams: function queryParams(params) {   //设置查询参数
                var param = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    name:$('#name').val(),
                    phone:$('#phone').val(),
                    grade:$('#grade').val(),
                    time:$('#KL-time').val(),
					res_status:$('#seaResStatus').val(),
                };
                return param;
            },
            onLoadSuccess: function(res){ //加载成功时执行
                if(111 == res.code){
                    window.location.reload();
                }
                layer.msg("加载成功", {time : 1000});
            },
            onLoadError: function(){  //加载失败时执行
                layer.msg("加载数据失败");
            },
			onDblClickRow: function (row) {
                // $("#remarks").html(row.remarks);
                layer.open({
                    type: 1,
                    skin: 'layui-layer-lan', //加上边框
                    area: ['400px', '200px'], //宽高
                    content: $("#trackInfo"),
                    title: '资源客源状态',
					btn:['确认','取消'],
					yes:function(){
						var mid = row.id;
						var resStatus = $('#resStatus').val();
						$.post("{:url('Business/resStatus')}",{
							resStatus:resStatus,
							mid:mid
						},function(data){
							if(data.code == 1){
								layer.msg('更新完成',{time : 1000},function(){
									layer.closeAll();
									initTable();
								});
							}else{
								layer.msg('数据错误',{time : 1000},function(){
									layer.closeAll();
									return false;
								});
							}
						})
					}
                });
            }
        });
    }

    $(document).ready(function () {
        //调用函数，初始化表格
        initTable();
        //当点击查询按钮的时候执行
        $("#search").bind("click", initTable);
    });

    //时间选择
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#KL-time'
            ,range: true
        });
    })
</script>
{/block}
